package com.tongna.crawler.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import jodd.http.HttpRequest;
import jodd.http.HttpResponse;

public class DataServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		try {
			new Thread(new Runnable() {

				public void run() {
					int max = 40057;
					for (int i = 1; i <= max; i++) {
						try {
							String url = "http://maotouying.bceapp.com/companydatax.htm?page=" + i;
							System.out.println("剩余:" + (max - i));
							HttpResponse response = HttpRequest.post(url).send();
							response.body();
						} catch (Exception e) {
							// TODO: handle exception
						}
						
					}

				}
			}).start();
		} catch (Exception e) {
			e.printStackTrace();
		}
		response.getWriter().append("ok");
		response.getWriter().flush();
	}
}
